package cn.getech.data.development.service.impl;

import cn.getech.data.development.entity.AlarmObject;
import cn.getech.data.development.mapper.AlarmObjectMapper;
import cn.getech.data.development.service.AlarmObjectService;
import cn.getech.data.intelligence.common.utils.Constant;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Service
public class AlarmObjectServiceImpl extends ServiceImpl<AlarmObjectMapper, AlarmObject> implements AlarmObjectService {

    @Resource
    private AlarmObjectMapper mapper;

    @Override
    public List<AlarmObject> listByWorkMenuId(Long workMenuId) {
        return mapper.selectList(new QueryWrapper<AlarmObject>().eq("object_id",workMenuId).eq("object_type", Constant.AlarmTypeEnum.TASK_ALARM.getCode()));
    }

    @Override
    public List<AlarmObject> listByalarmId(Long alarmid) {
        return mapper.selectList(new QueryWrapper<AlarmObject>().eq("alarm_id",alarmid).eq("object_type", Constant.AlarmTypeEnum.TASK_ALARM.getCode()));
    }

    @Override
    public List<AlarmObject> listWorkFlowByWorkMenuIds(Set<Long> olderWorkMenuIds, int objType) {
        return mapper.listWorkFlowByWorkMenuIds(olderWorkMenuIds,objType);
    }

    @Override
    public void deleteWorkFlowRulesByWorkFlowIds(Set<Long> workFlowIds, int objType) {
        mapper.delete(new QueryWrapper<AlarmObject>().eq("object_type",objType).in("object_id",workFlowIds));
    }
}
